Remove favorites flag system, consolidate to collection-based grouping#2
Remove favorites flag system, consolidate to collection-based grouping#2
Conversation
Co-authored-by: linhdmn <13645510+linhdmn@users.noreply.github.com>
Co-authored-by: linhdmn <13645510+linhdmn@users.noreply.github.com>
Co-authored-by: linhdmn <13645510+linhdmn@users.noreply.github.com>
Co-authored-by: linhdmn <13645510+linhdmn@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR removes the redundant favorites flag-based system and consolidates request organization into the collection-based hierarchical grouping system. The change eliminates duplicate state management by removing the boolean isUserFavorite flag system that provided a flat list, while keeping the more powerful collection-based folder support.
Changes:
- Removed favorites state management and UI (tabs, icons, handlers) from frontend and backend
- Removed
isUserFavoriteandfavoritedTimefields from request state interfaces - Deleted
filterDuplicatesFromObjectutility and associated favorites constants - Simplified sidebar menu to show only Collections and History tabs
Reviewed changes
Copilot reviewed 18 out of 21 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| webview/store/slices/type.d.ts | Removed favorites-related properties from interfaces (isUserFavorite, favoritedTime, userFavorites, and handler methods) |
| webview/store/slices/sidebarSlice.ts | Removed favorites state slice and all favorites-related handler functions |
| webview/features/Sidebar/Menu/SidebarMenuOption.tsx | Simplified handlers to only work with history collection, removed favorites case from switch statement |
| webview/features/Sidebar/Menu/SidebarMenu.tsx | Removed favorites message handling and state updates |
| webview/features/Sidebar/Menu/SidebarEmptyCollectionMenu.tsx | Removed favorites empty state import and simplified conditional rendering |
| webview/features/Sidebar/Collection/SidebarCollection.tsx | Removed heart icon imports and favorites toggle functionality from collection items |
| webview/constants/sidebar.ts | Removed favorites-related constants (FAVORITES, ADD_TO_FAVORITES, REMOVE_FROM_FAVORITES, USER_FAVORITES_COLLECTION, FAVORITES_COLLECTION) |
| webview/constants/options.ts | Removed "Favorites" from sidebar menu options array |
| webview/components/MoreInformation.tsx | Removed favorite heart icon styling |
| src/utils/type.d.ts | Removed isUserFavorite and favoritedTime from request state interface |
| src/utils/index.ts | Removed export of filterDuplicatesFromObject utility |
| src/utils/filterDuplicatesFromObject.ts | Deleted entire utility file used for favorites deduplication |
| src/extension/utils/type.d.ts | Removed isUserFavorite and favoritedTime from request state interface |
| src/extension/utils/index.ts | Removed export of filterDuplicatesFromObject utility |
| src/extension/utils/filterDuplicatesFromObject.ts | Deleted entire utility file used for favorites deduplication |
| src/extension/extension.ts | Removed favorites collection initialization on extension activation |
| src/extension/constants/command.ts | Removed favorites command constants |
| src/extension/constants/collection.ts | Removed favorites collection constant and filterable keys |
| src/extension/SidebarWebViewPanel.ts | Removed favorites data retrieval, message handling for add/remove favorites operations, and favorites parameter from update method |
| src/extension/MainWebViewPanel.ts | Removed isUserFavorite and favoritedTime initialization when creating request history items |
| src/extension/ExtensionStateManger.ts | Removed favorites state update logic and filterDuplicatesFromObject import from updateExtensionContext method |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| async updateExtensionContext(state: string, id: string, status?: string) { | ||
| const currentTime = new Date().getTime(); | ||
| const globalHistoryState: IUserRequestSidebarState[] | undefined = | ||
| this.context.globalState.get(state); | ||
| const globalFavoritesState: IUserRequestSidebarState[] | undefined = | ||
| this.context.globalState.get(COLLECTION.FAVORITES_COLLECTION); | ||
|
|
||
| if (!globalHistoryState || !globalFavoritesState) return; | ||
|
|
||
| globalHistoryState.map( | ||
| (history) => | ||
| history.id === id && | ||
| ((history.isUserFavorite = !history.isUserFavorite), | ||
| (history.favoritedTime = currentTime)), | ||
| ); | ||
| if (!globalHistoryState) return; | ||
|
|
||
| // No favorites update needed anymore | ||
| await this.context.globalState.update(state, [...globalHistoryState]); | ||
|
|
||
| if (status) { | ||
| const duplicateFilteredUserFavoriteCollection = | ||
| filterDuplicatesFromObject( | ||
| globalHistoryState, | ||
| globalFavoritesState, | ||
| id, | ||
| ); | ||
|
|
||
| await this.context.globalState.update(COLLECTION.FAVORITES_COLLECTION, [ | ||
| ...duplicateFilteredUserFavoriteCollection, | ||
| ]); | ||
| } | ||
| } |
There was a problem hiding this comment.
The updateExtensionContext method now only retrieves the state and immediately updates it with the same data without any modifications. The id and status parameters are no longer used. Consider removing this method entirely or clarifying its purpose, as it currently performs no meaningful operation.
There was a problem hiding this comment.
Removed the unused method in commit 13b1181. It was only performing a no-op after favorites were removed.
|
@copilot how to validate your changes work? |
Co-authored-by: linhdmn <13645510+linhdmn@users.noreply.github.com>
To validate the changes:
Expected UI changes:
|
Summary: Replace Favorites with Collection-based Grouping ✅
Problem Solved: The codebase had two conflicting systems:
Users could not organize or group favorite requests into folders.
Solution Implemented: Removed the favorites flag system entirely. Now users organize requests exclusively through the Collections system, which supports hierarchical grouping with folders.
Changes Made
Backend Changes
isUserFavoriteandfavoritedTimefields fromIUserRequestSidebarStatetypeFAVORITES_COLLECTIONand favorites-related constantsADD_TO_FAVORITESandREMOVE_FROM_FAVORITEScommandsExtensionStateMangerto remove favorites state managementupdateExtensionContextmethod (was only used for favorites)SidebarWebViewPanelto not send/handle favorites dataMainWebViewPanelto remove favorites initialization and togglesfilterDuplicatesFromObjectutility functionsFrontend Changes
sidebarSliceto remove favorites state and handlers:userFavoritesstatehandleUserFavoritesCollectionhandleUserFavoriteIconaddCollectionToFavoritesremoveFromFavoriteCollectionresetFavoriteIconStateSIDEBARSidebarMenuOptionto remove favorites toggle logicSidebarMenuto not process favorites messagesSidebarCollectionSidebarEmptyCollectionMenuto not show favorites empty stateMoreInformationcomponentBuild & Quality Checks
How to Validate
Build the extension:
Install in VS Code:
Test the changes:
Expected behavior:
Impact
Before:
After:
Security Summary
✅ No vulnerabilities found - CodeQL JavaScript analysis completed with 0 alerts
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.